import request from '@/utils/request'

/**
 * 添加宠物
 * @param {*} data
 */
export const addPet = async (data) => {
    return request({
        url: '/pets',
        method: 'post',
        data
    })
}

/**
 *  获取宠物列表
 *  @param {*} offset 当前页
 *  @param {*} limit 每页显示条数
 */

export const getPetList = async (offset, limit) => {
    return request({
        url: '/pets',
        method: 'get',
        params: {
            offset,
            limit
        }
    })
}

/**
 *  获取宠物列表(搜索)
 *  @param {*} offset 当前页
 *  @param {*} limit 每页显示条数
 */

export const getPetListByKey = async (offset, limit, keyword) => {
    return request({
        url: '/pets',
        method: 'get',
        params: {
            offset,
            limit,
            keyword
        }
    })
}

/**
 *  删除宠物
 *  @param {*} petId 宠物id
 */

export const deletePet = async (petId) => {
    return request({
        url: `/pets/${petId}`,
        method: 'delete'
    })
}
/**
 *  绑定设备
 *  @param {*} petId 宠物id
 */

export const bindDevice = async (petId, data) => {
    return request({
        url: `/pets/${petId}/device`,
        method: 'put',
        data
    })
}
/**
 *  解绑设备
 *  @param {*} petId 宠物id
 */

export const unbindDevice = async (petId) => {
    return request({
        url: `/pets/${petId}/device`,
        method: 'delete'
    })
}